package mTree;

import giny.model.Node;
import multilevelLayoutPlugin.NodePositionManager;

public class MTreeNode {

    private double parentDistance = 0;

    private double coveringRadius = 0;

    private MTree subtree;

    private MTree container;

    private final Node graphNode;

    public MTreeNode(final Node n) {
        graphNode = n;
    }

    public double getCoveringRadius() {
        return coveringRadius;
    }

    public double getParentDistance() {
        return parentDistance;
    }

    public MTree getSubtree() {
        return subtree;
    }

    public Node getGraphNode() {
        return graphNode;
    }

    public double distance(final MTreeNode n, final NodePositionManager posman) {
        final double x1 = posman.getX(graphNode.getRootGraphIndex());
        final double x2 = posman.getX(n.getGraphNode().getRootGraphIndex());
        final double y1 = posman.getY(graphNode.getRootGraphIndex());
        final double y2 = posman.getY(n.getGraphNode().getRootGraphIndex());
        return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }

    public MTree getContainer() {
        return container;
    }

    public void setCoveringRadius(final double r) {
        coveringRadius = r;
    }

    public void setParentDistance(final double d) {
        parentDistance = d;
    }

    public void setContainer(final MTree m) {
        container = m;
    }

    public void setSubtree(final MTree m) {
        subtree = m;
    }
}
